home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1999 March / EnigmA AMIGA RUN 35 (1999)(G.R. Edizioni)(IT)[!][issue 1999-03].iso / earkit / mail / thor / thor231u.lha / rexx / KeepMsg.thor next >
Text File  |  1996-04-01  |  5KB  |  162 lines

  1. /*
  2. ** $VER: KeepMsg.thor 1.3b (1.4.95)
  3. ** by Eirik Nicolai Synnes <eirikns@sn.no>
  4. **
  5. ** Copies the current or selected message to a special "Keep" conference and
  6. ** sets the KEEP flag on them.
  7. **
  8. ** Specify the conference name in the toconf string below. If the conference
  9. ** doesn't exist it will be created.
  10. **
  11. ** If you don't want the copy in the destination conference to be marked as
  12. ** unread make sure nomarkmsg is set to 1 below. Otherwise set it to 0.
  13. **
  14. ** Fixed in 1.3a:
  15. ** o Fixed a bug where the keep conference wouldn't be created if it didn't
  16. **   already exist
  17. **
  18. ** Fixed in 1.3b:
  19. ** o When no messages were selected the current message should have been
  20. **   copied, but it wasn't. Fixed.
  21. */
  22.  
  23. toconf  = 'The Keep'
  24. nomarkmsg = 0
  25.  
  26. options results
  27. options failat 30
  28.  
  29. signal on syntax
  30. signal on halt
  31. signal on break_c
  32.  
  33. CDF_NOT_ON_BBS   = '00008000'x  /* This conference is not on the bbs. */
  34.  
  35. /* Open Thor and BBSREAD ARexx ports' */
  36.  
  37. p=address()||' '||show('P',,)
  38. if pos('THOR.',p)>0 then thorport=word(substr(p,pos('THOR.',p)),1)
  39. else do
  40.     say 'No THOR port found!'
  41.     exit(0)
  42.     end
  43.  
  44. if ~show('p', 'BBSREAD') then do
  45.     address command; "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead"
  46.     "WaitForPort BBSREAD"
  47.     if rc ~= 0 then do
  48.         address(thorport)
  49.         REQUESTNOTIFY '"Couldn''t open BBSRead''s ARexx port."' '"I see"'
  50.         exit(0)
  51.         end
  52.     end
  53.  
  54. address(thorport)
  55. trace off; CURRENTMSG curmsg; trace on
  56. if rc ~= 0 then do
  57.     REQUESTNOTIFY '"CURRENTMSG:\n'THOR.LASTERROR'"' '"Abort"'
  58.     exit(0)
  59.     end
  60.  
  61. GETMSGLISTSELECTED msgsel
  62. if rc = 3 | rc = 5 then do
  63.     msgsel.1 = curmsg.MSGNR; msgsel.COUNT = 1
  64.     end
  65. else if rc ~= 0 then do
  66.     REQUESTNOTIFY '"GETMSGLISTSELECTED:\n'THOR.LASTERROR'"' '"Abort"'
  67.     exit(0)
  68.     end
  69.  
  70. if msgsel.COUNT = 0 then do
  71.     msgsel.1 = curmsg.MSGNR; msgsel.COUNT = 1
  72.     end
  73.  
  74. address(bbsread)
  75. BUFMODE COPYBACK
  76.  
  77. do i = 1 to msgsel.COUNT
  78.     drop data. head. text.
  79.  
  80.     address(bbsread)
  81.     READBRMESSAGE '"'curmsg.BBSNAME'"' '"'curmsg.CONFNAME'"' '"'msgsel.i'"' TEXTSTEM text HEADSTEM head DATASTEM data
  82.     if rc ~= 0 then do
  83.         address(thorport)
  84.         REQUESTNOTIFY '"READBRMESSAGE (message #'msgsel.i'):\n 'BBSREAD.LASTERROR'"' '"Abort"'
  85.         signal cleanup
  86.         end
  87.  
  88.     if text.TEXT.COUNT = 0 & (text.PART.COUNT = 0 | symbol('text.PART.COUNT') ~= 'VAR') then do
  89.         address(thorport)
  90.         REQUESTNOTIFY '"No message body (message #'msgsel.i').\nMessage not copied."' '"'_Ok'"'
  91.         signal cleanup
  92.         end
  93.  
  94.     text.replyconf = curmsg.CONFNAME
  95.  
  96.     if head.fromname        ~= "HEAD.FROMNAME"        then text.fromname        = head.fromname
  97.     if head.fromaddr        ~= "HEAD.FROMADDR"        then text.fromaddr        = head.fromaddr
  98.     if head.toname          ~= "HEAD.TONAME"          then text.toname          = head.toname
  99.     if head.toaddr          ~= "HEAD.TOADDR"          then text.toaddr          = head.toaddr
  100.     if head.msgid           ~= "HEAD.MSGID"           then text.msgid           = head.msgid
  101.     if head.refid           ~= "HEAD.REFID"           then text.refid           = head.refid
  102.     if head.creationdate    ~= "HEAD.CREATIONDATE"    then text.creationdate    = head.creationdate
  103.     if head.creationdatetxt ~= "HEAD.CREATIONDATETXT" then text.creationdatetxt = head.creationdatetxt
  104.     if head.subject         ~= "HEAD.SUBJECT"         then text.subject         = head.subject
  105.  
  106.     red = ""; priv = ""; urg = ""; imp = ""; conf = ""
  107.     if bittst(data.flags, 0)  then red  = "READ"
  108.     if bittst(data.flags, 2)  then priv = "PRIVATE"
  109.     if bittst(data.flags, 11) then urg  = "URGENT"
  110.     if bittst(data.flags, 12) then imp  = "IMPORTANT"
  111.     if bittst(data.flags, 17) then conf = "CONFIDENTIAL"
  112.  
  113.     if nomarkmsg then nomark = 'DONTMARKMESSAGE'
  114.     else nomark = ''
  115.  
  116.     WRITEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' STEM text nomark red priv urg imp conf
  117.     if rc = 7 then do
  118.         CONFIGCONF '"'curmsg.BBSNAME'"' '"'toconf'"' SET c2x(CDF_NOT_ON_BBS)
  119.         WRITEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' STEM text nomark red priv urg imp conf
  120.         if rc ~= 0 then do
  121.             address(thorport)
  122.             REQUESTNOTIFY '"WRITEBRMESSAGE:\n'BBSREAD.LASTERROR'"' '"_Ok"'
  123.             signal cleanup
  124.             end
  125.         end
  126.     else if rc ~= 0 then do
  127.         address(thorport)
  128.         REQUESTNOTIFY '"WRITEBRMESSAGE:\n'BBSREAD.LASTERROR'"' '"_Ok"'
  129.         signal cleanup
  130.         end
  131.  
  132.     mnr = result
  133.     repl = ""
  134.     if bittst(data.flags, 1) then repl = "SETREPLIED"
  135.  
  136.     address(bbsread)
  137.     UPDATEBRMESSAGE '"'curmsg.BBSNAME'"' '"'toconf'"' mnr SETKEEP repl HAZELEVEL data.HAZELEVEL
  138.     if rc ~= 0 then do
  139.         address(thorport)
  140.         REQUESTNOTIFY '"UPDATEBRMESSAGE:\n'BBSREAD.LASTERROR'"' '"_Ok"'
  141.         signal cleanup
  142.         end
  143.     end
  144.  
  145. address(thorport)
  146. UPDATECONFWINDOW
  147.  
  148. signal cleanup
  149.  
  150. error:
  151. halt:
  152. break_c:
  153.  
  154. if rc ~= 0 then say '+++ Line 'sigl' returned 'rc': 'errortext(rc)
  155.  
  156. cleanup:
  157.  
  158. address(bbsread)
  159. BUFMODE ENDCOPYBACK
  160.  
  161. exit(0)
  162.